//2566.替换一个数字后的最大差值
//https://leetcode.cn/problems/maximum-difference-by-remapping-a-digit/
class Solution {
public:
    int minMaxDifference(int num) {
        string s(to_string(num));
        char ch = s[0];
        for(char& c:s)
        {
            if(c != '9')
            {
                ch = c;
                break;
            }
        }

        for(char& c:s) if(c ==  ch) c = '9';
        int maxn = stoi(s);
        s = to_string(num);
        ch = s[0];
        for(char& c:s) if(c ==  ch) c = '0';
        return maxn-stoi(s);
    }
};